from time import sleep
from datetime import datetime, time


def time_delta_test():
    dt = datetime.now().replace(day=27, hour=17)
    dt_now = datetime.now()

    delta_time = dt_now - dt
    print(delta_time)
    print(delta_time.days)
    print(delta_time.seconds)
    # 结论：小于1天，出来的days是为0

"""
dt = datetime.now().replace(hour=12)
dt_now = datetime.now()
if dt_now.day == dt_now.day:
    print(True)

dt_now.timestamp()
"""


def datetime_time_test():
    dt_now = datetime.now()
    print(dt_now)
    print(dt_now.minute)
    print(dt_now.second)


def time_test():
    time_list = []
    for h, m in [(10,15), (11,30), (15,54), (23,0)]:
        time_list.append(time(h, m))
    print(time_list)
    dt = datetime.now()
    for t in time_list:
        if dt.time() < t:
            delta_s = dt.replace(hour=t.hour, minute=t.minute, second=0, microsecond=0) - dt
            print(t, delta_s.seconds)
            break


if __name__ == '__main__':
    #datetime_time_test()
    #time_test()
    dt_now = datetime.now()
    sleep(3)
    dt_now_1 = datetime.now()
    dt = dt_now_1 -dt_now
    print("second", dt.total_seconds())
    print("microsecond", dt.microseconds)
